{% extends 'base.html' %}

{% block title %}发布问答{% endblock %}
{% block head %}
    <link rel="stylesheet" href="{{ url_for('static',filename = 'css/question.css') }}">
     <script type="text/javascript" src="{{ url_for('static',filename='showdown-master/dist/showdown.min.js') }}"></script>
{% endblock %}

{% block main %}
    <h3 class="page-title">发布问答</h3>
    <form action="" method="post">
        <div class="form-container">
            <div class="form-group">
                <input type="text" placeholder="请输入标题" name="title" class="form-control">
            </div>
            <div class="form-group">
                <textarea  cols="30" rows="20" name="content" id="form-content" class="form-control" onkeyup="convert()" ></textarea>
            </div>
            <div class="form-group">
                <button class="btn btn-primary">立即发布</button>
            </div>

        </div>
    </form>
    <hr>
    <h3>预览：</h3>
            <div id="pre-view"></div>
            <script type="text/javascript">
            function convert(){

                        {#var text = "{{ question.content }}"#}
                        var text = document.getElementById("form-content").value;
                        {#console.log(typeof(text));#}
                        var converter = new showdown.Converter();
                        var html = converter.makeHtml(text);
                        document.getElementById("pre-view").innerHTML = html;
            }

                    </script>
{% endblock %}
